﻿// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// 
// Copyright (c) 2012, Dr. Masroor Ehsan
// All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//    * Redistributions of source code must retain the above copyright
//      notice, this list of conditions and the following disclaimer.
//    * Redistributions in binary form must reproduce the above copyright
//      notice, this list of conditions and the following disclaimer in the
//      documentation and/or other materials provided with the distribution.
//    * Neither the name of the <organization> nor the
//      names of its contributors may be used to endorse or promote products
//      derived from this software without specific prior written permission.
// 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// 
// $Id: ResultCode.cs 12 2012-01-27 06:11:46Z masroore@gmail.com $
// 
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

using System.Collections.Generic;

namespace LWObjects
{
    public class ResultCode : IAlaSerializable
    {
        public string Code { get; set; }
        public string Name { get; set; }
        public string MethodName { get; set; }
        public string ReferenceRange { get; set; }
        public string Units { get; set; }
        public string MajorSort { get; set; }
        public string MinorSort { get; set; }
        public string IgnoreUniqueness { get; set; }
        public string AppendValues { get; set; }
        public string PerformingLabId { get; set; }

        #region IAlaSerializable Members

        public string Serialize()
        {
            var fields = new List<string>(Utilities.ALA_FIELDS_COUNT);
            for (var i = 0; i < Utilities.ALA_FIELDS_COUNT; i++)
                fields.Add(string.Empty);

            fields[0] = "RC";
            fields[1] = Code;
            fields[2] = Name;
            fields[3] = MethodName;
            fields[4] = ReferenceRange;
            fields[5] = Units;
            fields[6] = MajorSort;
            fields[7] = MinorSort;
            fields[8] = IgnoreUniqueness;
            fields[9] = AppendValues;
            fields[10] = PerformingLabId;

            return Utilities.AlaJoinFields(fields);
        }

        public void Deserialize(string data)
        {
            var fields = Utilities.AlaSplitFields(data);
            Code = fields[1];
            Name = fields[2];
            MethodName = fields[3];
            ReferenceRange = fields[4];
            Units = fields[5];
            MajorSort = fields[6];
            MinorSort = fields[7];
            IgnoreUniqueness = fields[8];
            AppendValues = fields[9];
            PerformingLabId = fields[10];
        }

        public void Reset()
        {
        }

        #endregion

        public override string ToString()
        {
            return Name;
        }
    }
}